<template>
  <view class="commonLim-list">
    <!-- 表单内容 -->
    <view class="form-content flexandauto">
      <view class="form-item">
        <view>
          <text class="label" style="color: red">*</text>
          <text class="label">退库编号:</text>
        </view>
        <view>
          <text v-if="profile.returnNo" class="iptClass">{{
            profile.returnNo
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label" style="color: red">*</text>
          <text class="label">原料编码:</text>
        </view>
        <view>
          <text v-if="profile.rawMaterialCode" class="iptClass">{{
            profile.rawMaterialCode
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">材质:</text>
        </view>
        <view>
          <text v-if="profile.materialTypeName" class="iptClass">{{
            profile.materialTypeName
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">规格型号:</text>
        </view>
        <view>
          <text v-if="profile.specificationName" class="iptClass">{{
            profile.specificationName
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">炉号:</text>
        </view>
        <view>
          <text v-if="profile.heatNo" class="iptClass">{{
            profile.heatNo
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">退库数量:</text>
        </view>
        <view>
          <text v-if="profile.returnQuantity" class="iptClass">{{
            profile.returnQuantity
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">退库原因:</text>
        </view>
        <view>
          <text v-if="profile.returnReason" class="iptClass">{{
            profile.returnReason
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">卷号:</text>
        </view>
        <view>
          <text v-if="profile.coilNo" class="iptClass">{{
            profile.coilNo
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">厂商:</text>
        </view>
        <view>
          <text v-if="profile.supplierName" class="iptClass">{{
            profile.supplierName
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">备注:</text>
        </view>
        <view>
          <text v-if="profile.remark" class="iptClass">{{
            profile.remark
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">退库人:</text>
        </view>
        <view>
          <text v-if="profile.returnByName" class="iptClass">{{
            profile.returnByName
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">退库日期:</text>
        </view>
        <view>
          <text v-if="profile.returnDate" class="iptClass">{{
            profile.returnDate
          }}</text>
        </view>
      </view>
      <view class="form-item">
        <view>
          <text class="label">领料编号:</text>
        </view>
        <view>
          <text v-if="profile.pickNo" class="iptClass">{{
            profile.pickNo
          }}</text>
        </view>
      </view>
    </view>
    <!-- 提交按钮 -->
    <view class="dengjiClass" v-if="compactivityName">
      <button @click="onSubmit" class="commonClass first">确认</button>
      <CancelMsg
        fromThatPage="退库申请详情"
        :currentObj="memberStore.currenttukutable"
        @fatherFn="fatherFn"
        style="flex: 1"
      />
    </view>
  </view>
</template>

<script setup>
import { materialReturnSumit } from "../ReturnList/api.js";
import { useMemberStore } from "@/stores/modules/member";
const memberStore = useMemberStore();
const deprops = defineProps(["title", "activityName"]);
const compactivityName = computed(() => deprops.activityName == "退库确认");
const profile = ref({});
// 点击提交表单
const onSubmit = async () => {
  try {
    uni.showLoading({
      title: "加载中",
    });
    await materialReturnSumit(memberStore.currenttukutable.id, {
      returnOrderId: memberStore.currenttukutable.id,
      suggestion: "同意",
      workflowWorkItemId: memberStore.currenttukutable.workflowWorkItemId,
    });
    uni.showToast({ icon: "success", title: "提交成功" });
    uni.navigateBack({ delta: 1 });
  } finally {
    uni.hideLoading();
  }
};
const fatherFn = () => {
  uni.navigateBack({ delta: 1 });
};
onLoad(async () => {
  uni.setNavigationBarTitle({
    title: deprops.title,
  });
  profile.value = memberStore.currenttukutable;
});
</script>

<style lang="scss" scoped>
// 表单
</style>
